//
//  SleepAverageView.swift
//  MoyoungHome
//
//  Created by 李然 on 2022/9/27.
//

import UIKit
import MYModule

import RxSwift
import RxCocoa


open class SleepAverageCell: SleepBaseCell {
    
    public let averageView = HeartRateChartLineView()
    

    public override func makeUI() {
        super.makeUI()
        
        bgView.addSubview(averageView)
      
        averageView.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-20)
        }
        

        
    }
    
    public override func bind(to cellType: SleepViewModel.CellType) {
        super.bind(to: cellType)
        
        guard let heartData = cellType.viewModel as? BehaviorRelay<HeartRateChartLineConfig?> else { return }
        
        heartData.subscribe(onNext:{ [weak self]  in
            
            self?.averageView.config = $0
            
            
        }).disposed(by: rx.disposeBag)

    }
    
   
   
   
}
